{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [],
   "source": [
    "from Bio.PDB.MMCIFParser import MMCIFParser\n",
    "parser = MMCIFParser()\n",
    "#导入mmcif结构文件\n",
    "structure = parser.get_structure('1d3z', '1d3z.cif')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "help(structre)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    " for model in structure:\n",
    "     for chain in model:\n",
    "         for residue in chain:\n",
    "             for atom in residue:\n",
    "                 print(atom)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('1d3z',)"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "structure.get_full_id()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_list=structure.get_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<Model id=0>,\n",
       " <Model id=1>,\n",
       " <Model id=2>,\n",
       " <Model id=3>,\n",
       " <Model id=4>,\n",
       " <Model id=5>,\n",
       " <Model id=6>,\n",
       " <Model id=7>,\n",
       " <Model id=8>,\n",
       " <Model id=9>]"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [],
   "source": [
    "chain_list=model_list[0].get_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<Chain id=A>]"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [],
   "source": [
    "res_list=chain_list[0].get_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<Residue MET het=  resseq=1 icode= >,\n",
       " <Residue GLN het=  resseq=2 icode= >,\n",
       " <Residue ILE het=  resseq=3 icode= >,\n",
       " <Residue PHE het=  resseq=4 icode= >,\n",
       " <Residue VAL het=  resseq=5 icode= >,\n",
       " <Residue LYS het=  resseq=6 icode= >,\n",
       " <Residue THR het=  resseq=7 icode= >,\n",
       " <Residue LEU het=  resseq=8 icode= >,\n",
       " <Residue THR het=  resseq=9 icode= >,\n",
       " <Residue GLY het=  resseq=10 icode= >,\n",
       " <Residue LYS het=  resseq=11 icode= >,\n",
       " <Residue THR het=  resseq=12 icode= >,\n",
       " <Residue ILE het=  resseq=13 icode= >,\n",
       " <Residue THR het=  resseq=14 icode= >,\n",
       " <Residue LEU het=  resseq=15 icode= >,\n",
       " <Residue GLU het=  resseq=16 icode= >,\n",
       " <Residue VAL het=  resseq=17 icode= >,\n",
       " <Residue GLU het=  resseq=18 icode= >,\n",
       " <Residue PRO het=  resseq=19 icode= >,\n",
       " <Residue SER het=  resseq=20 icode= >,\n",
       " <Residue ASP het=  resseq=21 icode= >,\n",
       " <Residue THR het=  resseq=22 icode= >,\n",
       " <Residue ILE het=  resseq=23 icode= >,\n",
       " <Residue GLU het=  resseq=24 icode= >,\n",
       " <Residue ASN het=  resseq=25 icode= >,\n",
       " <Residue VAL het=  resseq=26 icode= >,\n",
       " <Residue LYS het=  resseq=27 icode= >,\n",
       " <Residue ALA het=  resseq=28 icode= >,\n",
       " <Residue LYS het=  resseq=29 icode= >,\n",
       " <Residue ILE het=  resseq=30 icode= >,\n",
       " <Residue GLN het=  resseq=31 icode= >,\n",
       " <Residue ASP het=  resseq=32 icode= >,\n",
       " <Residue LYS het=  resseq=33 icode= >,\n",
       " <Residue GLU het=  resseq=34 icode= >,\n",
       " <Residue GLY het=  resseq=35 icode= >,\n",
       " <Residue ILE het=  resseq=36 icode= >,\n",
       " <Residue PRO het=  resseq=37 icode= >,\n",
       " <Residue PRO het=  resseq=38 icode= >,\n",
       " <Residue ASP het=  resseq=39 icode= >,\n",
       " <Residue GLN het=  resseq=40 icode= >,\n",
       " <Residue GLN het=  resseq=41 icode= >,\n",
       " <Residue ARG het=  resseq=42 icode= >,\n",
       " <Residue LEU het=  resseq=43 icode= >,\n",
       " <Residue ILE het=  resseq=44 icode= >,\n",
       " <Residue PHE het=  resseq=45 icode= >,\n",
       " <Residue ALA het=  resseq=46 icode= >,\n",
       " <Residue GLY het=  resseq=47 icode= >,\n",
       " <Residue LYS het=  resseq=48 icode= >,\n",
       " <Residue GLN het=  resseq=49 icode= >,\n",
       " <Residue LEU het=  resseq=50 icode= >,\n",
       " <Residue GLU het=  resseq=51 icode= >,\n",
       " <Residue ASP het=  resseq=52 icode= >,\n",
       " <Residue GLY het=  resseq=53 icode= >,\n",
       " <Residue ARG het=  resseq=54 icode= >,\n",
       " <Residue THR het=  resseq=55 icode= >,\n",
       " <Residue LEU het=  resseq=56 icode= >,\n",
       " <Residue SER het=  resseq=57 icode= >,\n",
       " <Residue ASP het=  resseq=58 icode= >,\n",
       " <Residue TYR het=  resseq=59 icode= >,\n",
       " <Residue ASN het=  resseq=60 icode= >,\n",
       " <Residue ILE het=  resseq=61 icode= >,\n",
       " <Residue GLN het=  resseq=62 icode= >,\n",
       " <Residue LYS het=  resseq=63 icode= >,\n",
       " <Residue GLU het=  resseq=64 icode= >,\n",
       " <Residue SER het=  resseq=65 icode= >,\n",
       " <Residue THR het=  resseq=66 icode= >,\n",
       " <Residue LEU het=  resseq=67 icode= >,\n",
       " <Residue HIS het=  resseq=68 icode= >,\n",
       " <Residue LEU het=  resseq=69 icode= >,\n",
       " <Residue VAL het=  resseq=70 icode= >,\n",
       " <Residue LEU het=  resseq=71 icode= >,\n",
       " <Residue ARG het=  resseq=72 icode= >,\n",
       " <Residue LEU het=  resseq=73 icode= >,\n",
       " <Residue ARG het=  resseq=74 icode= >,\n",
       " <Residue GLY het=  resseq=75 icode= >,\n",
       " <Residue GLY het=  resseq=76 icode= >]"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [],
   "source": [
    "res=res_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Residue MET het=  resseq=1 icode= >"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {},
   "outputs": [],
   "source": [
    "atom_list=res.get_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<Atom N>,\n",
       " <Atom CA>,\n",
       " <Atom C>,\n",
       " <Atom O>,\n",
       " <Atom CB>,\n",
       " <Atom CG>,\n",
       " <Atom SD>,\n",
       " <Atom CE>,\n",
       " <Atom H1>,\n",
       " <Atom H2>,\n",
       " <Atom H3>,\n",
       " <Atom HA>,\n",
       " <Atom HB2>,\n",
       " <Atom HB3>,\n",
       " <Atom HG2>,\n",
       " <Atom HG3>,\n",
       " <Atom HE1>,\n",
       " <Atom HE2>,\n",
       " <Atom HE3>]"
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "atom_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Atom CA>"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "atom_list[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 51.653, -89.304,   8.833], dtype=float32)"
      ]
     },
     "execution_count": 122,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "atom_list[1].coord"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
